Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a dedicated substitution naming provider #377

Merged
merged 2 commits into from
May 16, 2023

Conversation

SmithPlatts
Copy link

Reason for PR

A need to specify alternate/replacement names for types and/or properties during generation, specifically from the command line.

Outline of key changes

  • Added new NamingProvider implementation, SubstituteNamingProvider, which can store a dictionary of generated names and an alternate to substitute with.
    • Updated the INamingProvider to add two specific Type-based methods for PropertyNameFromAttribute and PropertyNameFromElement, to ensure that custom implementors can split the implementation accordingly.
  • Updated XmlSchemaClassGenerator.Console to accept new command line options:
    • --typeNameSubstitute: For each instance, the {generated}={substituted} value is added to a collection.
    • --typeNameSubstituteFile: For each instance, the containing {generated} = {substituted} lines are added to a collection.
  • Updated README to properly document and define cli usage.

Related issues:

This may not completely solve all of these issues, but should at least assist with the next steps.

Requests for mercy

  • I have not (yet) added tests, as there aren't tests for the base capability (NamingProvider). I have submitted this PR as I have a desire for this to be merged before I am able to make time to add tests for both the NamingProvider and SubstituteNamingProvider implementations. May I request your mercy, and have tests overlooked for this specific PR?

Adam Smith-Platts added 2 commits April 27, 2023 21:37
… dictionary of generated names and an alternate to substitute with

- Updated the INamingProvider to add two specific Type-based methods for PropertyNameFromAttribute and PropertyNameFromElement, to ensure that custom implementors can split the implementation accordingly.
- Updated XmlSchemaClassGenerator.Console to take in command line options for --typeNameSubstitute and typeNameSubstituteFile.

What's left:

- Update README
- Add tests
@codecov
Copy link

codecov bot commented Apr 30, 2023

Codecov Report

Patch coverage: 8.88% and project coverage change: -1.32 ⚠️

Comparison is base (870d816) 95.52% compared to head (a00972e) 94.21%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #377      +/-   ##
==========================================
- Coverage   95.52%   94.21%   -1.32%     
==========================================
  Files          20       21       +1     
  Lines        2930     2973      +43     
  Branches      462      466       +4     
==========================================
+ Hits         2799     2801       +2     
- Misses         74      115      +41     
  Partials       57       57              
Impacted Files Coverage Δ
XmlSchemaClassGenerator/EnumerableExtensions.cs 86.74% <0.00%> (-10.56%) ⬇️
...erator/NamingProviders/SubstituteNamingProvider.cs 0.00% <0.00%> (ø)
XmlSchemaClassGenerator/ModelBuilder.cs 98.12% <100.00%> (ø)
XmlSchemaClassGenerator/NamingProvider.cs 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mganss mganss merged commit 8836a11 into mganss:master May 16, 2023
@mganss
Copy link
Owner

mganss commented May 16, 2023

Thanks a lot! Would be great if you could add unit tests.

@SmithPlatts
Copy link
Author

Hi @mganss! Thanks heaps for the merge!

Yes, I will work on tests for the NamingProvider base and the two implementations next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants